#include<bits/stdc++.h>
using namespace std;

const int Maxn=8e5+10; 
const int INF=1e9;
int N,A[Maxn],B[Maxn],C[Maxn],hed[Maxn],cnt;
int ans;
struct node{
	int nxt,to,num;
}G[Maxn<<1];

inline int read(){
	int ret=0,f=0; char ch=getchar();
	while(!isdigit(ch)){if(ch=='-') f=1; ch=getchar();}
	while(isdigit(ch)) ret=(ret<<1)+(ret<<3)+(ch^48),ch=getchar();
	return f?-ret:ret;
}

void Addedge(int x,int y,int z){
	G[++cnt].nxt=hed[x]; G[cnt].to=y; G[cnt].num=z; hed[x]=cnt;
}

void DFS(int x,int p,int in,int t1,int t2,int f){
	if(x!=f) ans+=in;
	for(int y,i=hed[x];i;i=G[i].nxt){
		if((y=G[i].to)==p) continue;
		if((x==t1&&y==t2)||(x==t2&&y==t1)) continue;
		DFS(y,x,min(in,G[i].num),t1,t2,f);
	}
}

int main(){
	freopen("tatooine.in","r",stdin);
	freopen("tatooine.out","w",stdout);
	N=read();
	for(int i=1;i<N;++i){
		A[i]=read(),B[i]=read(),C[i]=read();
		Addedge(A[i],B[i],C[i]); Addedge(B[i],A[i],C[i]);
	}
	for(int i=1;i<N;++i){
		ans=0;
		for(int j=1;j<=N;++j){
			DFS(j,0,INF,A[i],B[i],j);
		}
		printf("%d\n",ans>>1);
	}
	return 0;
}
